using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using RayDen.Library.Core.Primitives;

namespace RayDen.Library.Core {
    using Library.Core.Primitives;

    public interface IRay {
        Point Origin { get; }
        Vector Direction { get; }
        Vector InvDirection { get; }

        float Min { get; }
        float Max { get; }

        Point Point( float distance );
        void SetSegment(float min, float max);

    }

    public struct RayHit {
        public float Distance;
        public float U, V;
        public UInt32 Index;

        public bool Miss() {
            return this.Index.Equals(0xffffffffu);
        }
    }

    public struct RayHits
    {
        public float[] Distance;
        public float[] U;
        public float[] V;
        public UInt32[] Index;

        public RayHits(RayHit[] data)
        {
            Distance = data.Select(i => i.Distance).ToArray();
            U = data.Select(i => i.U).ToArray();
            V = data.Select(i => i.V).ToArray();
            Index = data.Select(i => i.Index).ToArray();
        }
    }
}